package com.yanqu.road.server.manger.activity.luckydraw;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.luckydraw.LuckyDrawConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.logic.bussiness.activity.LuckyDrawBusiness;
import com.yanqu.road.logic.config.ChannelConfig;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.luckydraw.LuckyDrawModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;

import java.util.List;

public class LuckyDrawMgr extends TempMgr {

    private static LuckyDrawConfig luckyDrawConfig;

    public static void reloadActivityData() {
        List<ActivityInfo> list = NormalActivityMgr.getOpenActivityInfoList(eActivityType.LuckyDrawActivity.getValue());
        if (list.isEmpty()) {
            return;
        }
        ActivityInfo activityInfo = list.get(0); // zkt wait todo 时区问题未处理

        LuckyDrawConfig tmpConfig = new LuckyDrawConfig();
        tmpConfig.setActivityInfo(activityInfo);
        tmpConfig.setRewardConfigList(LuckyDrawBusiness.getLuckyDrawRewardConfigList(ChannelConfig.CHANNEL_CENTER_DB_PARAM, activityInfo.getActivityId()));
        luckyDrawConfig = tmpConfig;

        for (GamePlayer gamePlayer : GamePlayerMgr.getAllOnlinePlayer()) {
            gamePlayer.getModule(LuckyDrawModule.class).refreshData();
        }
    }

    public static LuckyDrawConfig getLuckyDrawConfig() {
        return luckyDrawConfig;
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }
}
